{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>编辑</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <input type="hidden" name="dai_id" value="{$user.dai_id}">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">代理姓名：</label>
                <div class="layui-input-block">
                    <input type="text" name="dai_name" value="{$user.dai_name}" lay-verify="required|realname" placeholder="代理姓名" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">代理手机号：</label>
                <div class="layui-input-block">
                    <input type="text" name="dai_phone" value="{$user.dai_phone}" lay-verify="required" placeholder="代理手机号" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">代理地址：</label>
                <div class="layui-input-block">
                    <input type="text" name="dai_dizhi" value="{$user.dai_dizhi}" lay-verify="required" placeholder="代理地址" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">代理区域（市）：</label>
                <div class="layui-input-block">
                    <select name="dai_shi" lay-verify="required" lay-search="">
                        {foreach name="citys" item="vo"}
                        <option value="{$vo.district_id}" {if $vo.district_id == $user.dai_shi}selected{/if}>{$vo.district}</option>
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
<script type="text/javascript" src="__JS__/Crop.js"></script>
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        form.verify({
            realname:[/^[\S]{2,10}$/,'姓名必须2到10字符，且不能出现空格']

        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('userEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Leader/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
                    }
                }
            })
        });
    });
</script>
</body>
</html>